import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface DeleteDimensionGroupById_ {
  /**
   * @description id
   */
  id: number;
}
export interface GetDimensionHintName_ {
  /**
   * @description 根据维度名称提示模糊筛选
   */
  cnName?: string;
}
export interface GetDimensionById_ {
  /**
   * @description 主键id
   */
  id: number;
}
export interface PutDimensionById_ {
  /**
   * @description 主键id
   */
  id: number;
}
export interface DeleteDimensionById_ {
  /**
   * @description 主键id
   */
  id: number;
}

export class Dimension {
  /**
   * 添加维度
   *
   * @tags 维度管理
   * @request POST: /dimension
   * @secure
   */
  postDimension = (body: defs.DimensionDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityDimensionVO>({
      url: `/dimension`,
      method: "POST",
      data: body,
      ...params,
    });

  /**
   * 删除维度
   *
   * @tags 维度管理
   * @request POST: /dimension/batch-delete
   * @secure
   */
  postDimensionBatchDelete = (ids: number[], params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityBoolean>({
      url: `/dimension/batch-delete`,
      method: "POST",
      data: ids,
      ...params,
    });

  /**
   * 添加维度分组
   *
   * @tags 维度管理
   * @request POST: /dimension/group
   * @secure
   */
  postDimensionGroup = (dimensionGroupDTO: defs.DimensionGroupDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/dimension/group`,
      method: "POST",
      data: dimensionGroupDTO,
      ...params,
    });

  /**
   * 修改维度分组
   *
   * @tags 维度管理
   * @request PUT: /dimension/group
   * @secure
   */
  putDimensionGroup = (dimensionGroupDTO: defs.DimensionGroupDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/dimension/group`,
      method: "PUT",
      data: dimensionGroupDTO,
      ...params,
    });

  /**
   * 查询维度分组树
   *
   * @tags 维度管理
   * @request GET: /dimension/group/root
   * @secure
   */
  getDimensionGroupRoot = (params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/dimension/group/root`,
      method: "GET",
      ...params,
    });

  /**
   * 删除维度分组
   *
   * @tags 维度管理
   * @request DELETE: /dimension/group/{id}
   * @secure
   */
  deleteDimensionGroupById = ({ id }: { id: number } | DeleteDimensionGroupById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/dimension/group/${id}`,
      method: "DELETE",
      ...params,
    });

  /**
   * 根据维度中文名称模糊查询
   *
   * @tags 维度管理
   * @request GET: /dimension/hint-name
   * @secure
   */
  getDimensionHintName = (query: { cnName?: string } | GetDimensionHintName_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListDimensionVO>({
      url: `/dimension/hint-name`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 获取维度列表
   *
   * @tags 维度管理
   * @request POST: /dimension/list
   * @secure
   */
  postDimensionList = (body: defs.DimensionQueryDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityPageInfoDimensionVO>({
      url: `/dimension/list`,
      method: "POST",
      data: body,
      ...params,
    });

  /**
   * 根据id查询
   *
   * @tags 维度管理
   * @request GET: /dimension/{id}
   * @secure
   */
  getDimensionById = ({ id }: { id: number } | GetDimensionById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityDimensionVO>({
      url: `/dimension/${id}`,
      method: "GET",
      ...params,
    });

  /**
   * 更新维度元数据信息
   *
   * @tags 维度管理
   * @request PUT: /dimension/{id}
   * @secure
   */
  putDimensionById = (
    { id }: { id: number } | PutDimensionById_,
    body: defs.DimensionDTO,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityDimensionVO>({
      url: `/dimension/${id}`,
      method: "PUT",
      data: body,
      ...params,
    });

  /**
   * 删除维度
   *
   * @tags 维度管理
   * @request DELETE: /dimension/{id}
   * @secure
   */
  deleteDimensionById = ({ id }: { id: number } | DeleteDimensionById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityBoolean>({
      url: `/dimension/${id}`,
      method: "DELETE",
      ...params,
    });
}

export default new Dimension();
